package class

import (
	"encoding/json"
	"errors"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

func init() {

	var b = client.Load("CaptainPeerage")
	if err := json.Unmarshal(b, &CaptainClassConfigs); err != nil {
		panic(err)
	}

	log.Info("Load CaptainPeerage.json success.")
}

type CaptainClassConfig struct {
	Class           int32   `json:"ID"` // 爵位ID
	Name            string  // 爵位名称
	Quality         int32   // 爵位品质
	CaptainLevelMax int32   // 船长最高等级
	TalentLevelMax  int32   // 天赋最高等级
	AttributeID     int32   // 属性ID
	Items           []int32 // 晋升消耗物品ID数组
}

var CaptainClassConfigs = map[int32]CaptainClassConfig{}

func GetByCaptainClass(class int32) (CaptainClassConfig, error) {

	var conf, ok = CaptainClassConfigs[class]
	if ok {
		return conf, nil
	}

	return CaptainClassConfig{}, errors.New(fmt.Sprintf("CaptainClass not found [%d]", class))
}
